package create.abstract_factory;

public class AnimalFactory extends AbstractFactory{

	@Override
	public Animal getAnimal(String name) {
		Animal animal;
		switch (name) {
		case "dog":
			animal = new Dog();
			break;
		case "cat":
			animal = new Cat();
			break;
		default:
			throw new RuntimeException("输入有误！");
		}
		return animal;
	}

	@Override
	public Shape getShape(String name) {	
		return null;
	}
}

interface Animal {
	void breed();
}

class Cat implements Animal{
	@Override
	public void breed() {
		System.out.println("----cat---");
	}
}

class Dog implements Animal {
	@Override
	public void breed() {
		System.out.println("--- dog ---");
	}
}